// -*- C++ -*-

#include <vector>
#include <iostream>
#include <stdexcept>
#include <coil/Properties.h>
#include <services/StateService/State.h>

#ifndef STATEMANAGER_H
#define STATEMANAGER_H

class StateManager
{
protected:
    bool m_is_updated;
    typedef std::map<std::string, StatePtr>::iterator StateItr;
    typedef std::pair<std::string, StatePtr> StatePair;
    std::map<std::string, StatePtr> m_states;
public:
    StateManager() : m_is_updated(true) {}
    virtual ~StateManager(){}
    virtual void addState(const StatePtr state);
    virtual void addStates(const RTMEUS::StateProfileList &profs);
    virtual void addStates(std::vector<StatePtr> &states);
    virtual void removeState(const std::string &name);
    virtual void removeStates(std::vector<std::string> &names);
    virtual void clear();
    virtual std::vector<std::string> getStateNames();
    virtual StatePtr &getState(const char *name);
    std::vector<StatePtr> getStates();
    void copyToState(const char *name, RTMEUS::State& state);
    void copyToStateList(RTMEUS::StateList &states);    
    void copyToStateSet(RTMEUS::StateSet &states);
    bool copyFromState(const RTMEUS::State &state);
    void copyFromStateList(const RTMEUS::StateList &states);    
    void copyFromStateSet(const RTMEUS::StateSet &states) {copyFromStateList(states.datalist);}
};

void operator<<=(StateManager& man, const RTMEUS::StateSet &states);
void operator>>=(StateManager& man, RTMEUS::StateSet &states);

#endif // STATEMANAGER_H
